<?php

class ConfigSchemes_Model extends Model {

    public function __construct(){
        parent::__construct();
    }

    public function getSchemes () {
        $query = "SELECT * FROM scheme";
        return $this->_db->select ($query);
    }
    
    public function getScheme ($id) {
        if (isset ($id)) {
            $query = "SELECT * FROM scheme WHERE id = $id";
            return $this->_db->select ($query);
        }
        return null;
    }
    
    public function addScheme ($name, $description) {
        $params = Array();
        $params['name'] = $name;
        $params['description'] = $description;
        $this->_db->insert ('scheme', $params);
        
        return true;
    }
    
    public function modifyScheme ($id, $name, $description) {
        $params = Array();
        $where = Array();
        $params['name'] = $name;
        $params['description'] = $description;
        $where['id'] = $id;
        $this->_db->update ('scheme', $params, $where);
        
        return true;
    }
    
    public function removeScheme ($id) {
        $this->_db->delete ('scheme', 'id = ' . $id);
        
        return true;
    }
}

?>